#ifndef __BITMAP_H__
#define __BITMAP_H__

#include <stdint.h>
#include <string.h>

#define BIT_SIZE 1024

typedef struct {
    uint64_t bits[BIT_SIZE / (8 * sizeof(uint64_t))];
} bitmap;

#define M_ZERO(b) memset(&(b), 0, sizeof(b))

#define M_SET(b, v) \
    ((b).bits[(v) / (8 * sizeof(uint64_t))] |= \
    (1UL << ((v) % (8 * sizeof(uint64_t)))))

#define M_CLR(b, v) \
    ((b).bits[(v) / (8 * sizeof(uint64_t))] &= \
    ~(1UL << ((v) % (8 * sizeof(uint64_t)))))

#define M_ISSET(b, v) \
    (((b).bits[(v) / (8 * sizeof(uint64_t))] & \
    (1UL << ((v) % (8 * sizeof(uint64_t))))) != 0)

#endif
